﻿//DebugLogListener.cs
//Copyright (c) 2013 StockSharp LLC, all rights reserved.
//This code module is part of StockSharp library.
//This code is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
//See the file License.txt for the license details.
//More info on: http://stocksharp.com

namespace StockSharp.Logging
{
	using System;
	using System.Diagnostics;

	/// <summary>
	/// Логгер стратегии, записывающий данные в отладочное окно.
	/// </summary>
	public class DebugLogListener : LogListener
	{
		/// <summary>
		/// Записать сообщение.
		/// </summary>
		/// <param name="message">Отладочное сообщение.</param>
		protected override void OnWriteMessage(LogMessage message)
		{
			switch (message.Level)
			{
				case LogLevels.Debug:
				case LogLevels.Info:
					Trace.TraceInformation("{0} {1}", message.Source.Name, message.Message);
					break;
				case LogLevels.Warning:
					Trace.TraceWarning("{0} {1}", message.Source.Name, message.Message);
					break;
				case LogLevels.Error:
					Trace.TraceError("{0} {1}", message.Source.Name, message.Message);
					break;
				default:
					throw new ArgumentOutOfRangeException("message");
			}
		}
	}
}